<?php

class programTeachersSmsForm extends BaseForm{
    public function configure(){
        
        $program = $this->getOption('program');
        if(!$program){
            throw new Exception('No program passed to sms form');
        }
        
        $q = $program->getAcceptedTeachersQuery();
        
        $this->setWidgets(array(
            'mobile_numbers'    => new sfCheckboxDoctrineWithAllWidget(array('model'=>'Teacher', 'expanded'=>true , 'multiple'=>true,'query'=>$q, 'key_method'=>'getMobile')),
            'sms_body'          => new sfWidgetFormTextarea()
        ));
        
        $this->setValidators(array(
            'mobile_numbers'    => new sfValidatorDoctrineChoice(array('model'=>'Teacher', 'multiple'=>true, 'query'=>$q, 'column'=>'mobile')),
            'sms_body'          => new sfValidatorString(array('required'=>true))
        ));
        
        $this->widgetSchema->setLabels(array(
           'mobile_numbers'  => 'Select teachers to send to',
           'sms_body'        => 'SMS Message Text'
        ));
        
        $this->widgetSchema->setNameFormat('program_sms_teach[%s]');        
        $this->setCustomFormatter();
    }
}